<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>删除快递信息</span>
			</div>
			<div class="content">
				<table>	
					<tr>
						<td class="text-right">快递单号</td><td class="content_right"><input id="number" class="input inline-input" placeholder="请输入运单号码" onblur="testNumber()"> <span id="find" class="btn btn-info">立即查找</span></td>
					</tr>
				</table>
			</div>
			
			
			<div class="header">
				<span>查找信息如下</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">快递单号</td><td class="content_right"><input class="input" placeholder=""></td>
					</tr>
					<tr>
						<td class="text-right">快递公司</td><td class="content_right"><input class="input" placeholder=""></td>
					</tr>
					<tr>
						<td class="text-right">收货人姓名</td><td class="content_right"><input class="input" placeholder=""></td>
					</tr>
					<tr>
						<td class="text-right">收货人手机</td><td class="content_right"><input class="input" placeholder=""></td>
					</tr>
					<tr>
						<td class="text-right">快递状态</td><td class="content_right" id="status"></td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span class="btn btn-info" id="delete">立即删除</span> </td>
					</tr>
				</table>
			</div>
		</div>
	</body>
	<script src="/qrcode/jquery2.1.4.js"></script>
	<script src="/layer/layer.js"></script>
	<script>
		$(".header:eq(1),.content:eq(1)").hide();

		function testNumber() {
			var insertNumber = /(^[1|2|3|4|5|6|7|8|9]\d{5,11}$)/;
			var num = $.trim($('input:eq(1)').val());
			if (insertNumber.test(num)) {
				flagNumber = true;
			} else {
				layer.msg("请输入6-12位数字的快递单号！");
				return false;
			}
		}

		var expressId = null;//给后面删除快递用
		$(function(){
			$("#find").click(function(){
				find(true);
			});

			$("#delete").click(function(){
				deleteExpress();
			});
		});

		function find() {//
			var windowId = layer.load();
			var number = $("#number").val();
			//把信息发送给服务器 get请求获取数据
			$.getJSON("/express/findByNumber.do", {number: number}, function (data) {//{number:number} 键值对
				layer.close(windowId);
				layer.msg(data.result);//弹窗提示查询得到的提示
				if (data.status == 0) {
					$(".header:eq(1),.content:eq(1)").fadeIn(1000);//淡入显示 对应的是hide()隐藏
					$("#delete").fadeIn(1000);//1000ms
					expressId = data.data.id;
					//设置的方法记住
					$("input:eq(1)").val(data.data.number);
					$("input:eq(2)").val(data.data.company);
					$("input:eq(3)").val(data.data.username);
					$("input:eq(4)").val(data.data.userPhone);
					$("input:eq(1),input:eq(2),input:eq(3),input:eq(4)").prop("disabled", true);//设置属性为disable 使得输入框内容不能被更改
					switch (data.data.status) {
							<!--0 审核中,1 待取件,2 已取件,3 已取消,4 已删除,5 异常-->
						case 0:
							$("#status").html("审核中");
							break;
						case 1:
							$("#status").html("待取件");
							break;
						case 2:
							$("#status").html("已取件");
							break;
						case 3:
							$("#status").html("已取消");
							break;
						case 4:
							$("#status").html("已删除");
							$("#delete").hide();
							break;
						case 5:
							$("#status").html("异常");
							break;
						default:break;
					}
				}
			});
		}

		function deleteExpress() {
			var windowId = layer.load();
			$.getJSON("/express/delete.do",{id:expressId},function(data){
				layer.close(windowId);
				layer.msg(data.result);
				if(data.status == 0){
					$(".header:eq(1),.content:eq(1)").hide();
				}
			});
		}
	</script>
</html>
